import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import {
  Tabbar,
  TabbarItem,
  Lazyload,
  Swipe,
  SwipeItem,
  Grid,
  GridItem,
  Search,
  Sidebar,
  SidebarItem,
  Form,
  Field,
  Button,
  Image as VanImage,
  NavBar,
  Icon,
  Tag,
  Cell,
  CellGroup,
  AddressEdit,
  AddressList,
  Area,
  Popup,
  SubmitBar,
  Card,
  Checkbox,
  CheckboxGroup,
  TreeSelect,
  GoodsAction,
  GoodsActionIcon,
  GoodsActionButton,
  Sku,
  Tab,
  Tabs,
  ContactCard,
  Sticky,
  Picker,
  PasswordInput,
  NumberKeyboard,
  Overlay,
  CountDown,
  Toast,
  Divider,
  Stepper,
  RadioGroup,
  Radio,
  Popover,
  DropdownMenu,
  DropdownItem
} from 'vant'

import {
  InfiniteScroll
} from 'mint-ui'

// 导入全局样式
import './assets/css/global.css'
import api from './api/index.js'

// 导入过滤器
// * as 代表导入文件中所有的方法，filters定义的一个别名
import * as filters from './filter/filters.js'
// main.js文件中遍历文件中的方法
// 拿到键filters后使用forEach遍历，把拿到的所有过滤器存储在Vue过滤器中
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

// Object.keys(filters).forEach(key => Vue.filter(key, filters[key]))
Vue.use(Tabbar).use(TabbarItem).use(Lazyload).use(Grid).use(GridItem).use(Search).use(Sidebar)
  .use(SidebarItem).use(Form).use(Field).use(Button).use(VanImage).use(Cell).use(CellGroup)
  .use(NavBar).use(Icon).use(Tag).use(InfiniteScroll).use(Swipe).use(SwipeItem).use(AddressEdit)
  .use(Area).use(Popup).use(SubmitBar).use(Card).use(Checkbox).use(CheckboxGroup).use(TreeSelect)
  .use(GoodsActionButton).use(GoodsActionIcon).use(GoodsAction).use(Sku).use(Tab).use(Tabs)
  .use(ContactCard).use(Sticky).use(Picker).use(PasswordInput).use(NumberKeyboard).use(Overlay)
  .use(CountDown).use(Toast).use(Divider).use(Stepper).use(AddressList).use(Radio).use(RadioGroup).use(Popover)
  .use(DropdownItem).use(DropdownMenu)
Vue.config.productionTip = false

Vue.prototype.$api = api

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
